import binascii

class Node:
	def __init__(self, data):
		self.data = data
		self.next = None

class LinkedList:
	def __init__(self):
		self.head = None
		self.tail = None

	def insert(self, data):
		node = Node(data)
		if self.head == None:
			self.head = node
		if self.tail != None:
			self.tail.next = node

		self.tail = node

	def delete(self, index):
		prev = None
		node = self.head
		k = 0
		while (node != Node) and (k < index):
			prev = node
			node = node.next
			k += 1

		if prev == None:
			self.head = node.next
		else:
			prev.next = node.next

	def printList(self):
		node = self.head
		while node != None:
			print node.data
			node = node.next


class RadixSort:
	def __init__(self, A):
		self.A = A


	def sort(self):
		noi = len(str(max(self.A))) + 1
		C = self.A
		mod = 10
		div = 1
		counter = 1
		while counter < noi:
			T = [[] for k in range(0, 10)]
			for k in C:
				temp = 0 if len(str(k)) < counter else int(str(k)[len(str(k)) - counter])
				T[temp].append(k)


			C = sum(T, [])
			counter += 1
			mod *= 10
			div *= 10
		return C

	def __str__(self, data):
		return data

A = [123, 54, 2, 124, 55, 9, 333]
R = RadixSort(A)
print R.sort()
